﻿@model KL.Store.Web.Models.WishListDetailModel
@using KL.Store.Core
<div class="content">
    <div class="breadcrumb col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="bcBorder"></div>
        <div class="bcLinks">
            <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
                <a href="/" itemprop="url">
                    <span itemprop="title">Anasayfa</span>
                </a>›
            </div>
            <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
                <a href="/WishLists/Index" itemprop="url">
                    <span itemprop="title">Listelerim</span>
                </a>
            </div>
        </div>
        <div class="bcBorder"></div>
    </div>
    <div class="clearfix"></div>
    <h1>@Model.ListName</h1>
    @if (Model.Products.Count > 0)
    {
        <div class="cart-info">
            <div class="shop-cart-wishlists">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <td class="image col-xs-1">Resim
                            </td>
                            <td class="name col-xs-3">Açıklama
                            </td>
                            <td class="quantity col-xs-2">Adet
                            </td>
                            <td class="quantity col-xs-2">Alınan
                            </td>
                            <td class="price col-xs-2">Birim Fiyat
                            </td>
                            <td class="total col-xs-2">Toplam
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Products)
                        {
                            <tr>
                                <td class="image">
                                    <a id="pr_@item.ProductId" class="prdLink" href="@item.LinkUrl">
                                        <img id="ip_@item.ProductId" src="@(Parameters.WebSiteImageUrl)/product-small/@(item.ProductId)_1.jpg" alt="@(item.ProductName.Replace("\"", ""))" /></a>
                                </td>
                                <td class="name">
                                    <a id="pl_@item.ProductId" class="prdLink" href="@item.LinkUrl">@(item.ProductName)</a>
                                    @if (!string.IsNullOrEmpty(@item.GiftBuyersText))
                                    {
                                        <br />
                                        <br />
                                        <font color="red">Alan kişi(ler): </font>@item.GiftBuyersText
                                    }
                                </td>
                                <td class="quantity">
                                    @if (item.QtyPurchased > 0)
                                    {
                                        @item.Qty.ToString("###,##0")
                                    }
                                    else
                                    { 
                                        <input type="text" id="qty_@(item.ListId)_@(item.ProductId)" value="@item.Qty.ToString("#####")" size="1" />
                                        <div class="wrapper mt5">
                                            <a id="up_@(item.ListId)_@(item.ProductId)" class="upLink">
                                                <img src="/Images/@(Parameters.Theme)/update.png" alt="Güncelle" title="Güncelle" /></a> &nbsp;<a id="rm_@(item.ListId)_@(item.ProductId)" class="rmLink"><img
                                            src="/Images/@(Parameters.Theme)/remove.png" alt="Sil" title="Sil" /></a>
                                        </div>
                                    }
                                </td>
                                <td class="quantity">
                                    @item.QtyPurchased.ToString("###,##0")
                                </td>
                                <td class="price alignright">
                                    @item.Price.ToString("#.00") @item.Currency
                                </td>
                                <td class="total alignright" style="border-right: 0;">
                                    @((item.Price * item.Qty).ToString("#.00")) @item.Currency
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    }
    else
    {
        <div class="bg-info bs-bgb" style="margin-bottom: 15px; color: #000000;">
            <span class="glyphicon glyphicon-info-sign"></span>&nbsp;Bu listeye henüz hiç ürün eklenmemiş.
        </div>
    }
    <a href="/WishLists/Index" class="btn btn-custom1 right"><span>Geri</span></a>
    <div class="clearfix"></div>
</div>
<script type="text/javascript">
    $('a.cgLink').click(function () {
        var qsId = $(this).attr('id').split("_")[1];
        $('#content').load('/Categories/Get', { id: qsId });
        return false;
    });
    $('a.prLink').click(function () {
        var qsId = $(this).attr('id').split("_")[1];
        $('#content').load('/Products/Get', { id: qsId });
        return false;
    });

    $('a.prdLink').click(function () {
        var qsId = $(this).attr('id').split("_")[1];
        $('#content').load('/Product/Get', { id: qsId });
        return false;
    });

    $('a.rmLink').click(function () {
        var qsId1 = $(this).attr('id').split("_")[1];
        var qsId2 = $(this).attr('id').split("_")[2];
        $('#getWishList').load('/WishList/Remove', { listId: qsId1, id: qsId2 }, function () { RefreshCartSummary(); });
        return false;
    });

    $('a.upLink').click(function () {
        var qsId1 = $(this).attr('id').split("_")[1];
        var qsId2 = $(this).attr('id').split("_")[2];
        var qty = $('#qty_' + qsId1.toString() + "_" + qsId2.toString()).val();
        $('#getWishList').load('/WishList/Update', { listId: qsId1, id: qsId2, qty: qty }, function () { RefreshCartSummary(); });
        return false;
    });

    function RefreshCartSummary() {
        $('#cart').load('/Cart/GetSummary', {});
    }
</script>
